CSharpTest.Net
Remove Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class : Remove Method

key
The key of the element to remove.

Glossary Item Box

Removes the element with the specified key from the IDictionary.

Syntax

Visual Basic (Declaration) 
Public Function Remove( _
   ByVal key As TKey _
) As Boolean
C# 
public bool Remove( 
   TKey key
)

Parameters

key
The key of the element to remove.

Return Value

true if the element is successfully removed; otherwise, false. This method also returns false if key was not found in the original IDictionary.

Example

Library/Library.Test/TestLurchTable.cs

C#Copy Code
LurchTableTest<int, string> test = new LurchTableTest<int, string>();
for (int i = 0; i < 10; i++)
    test.Add(i, i.ToString());
            
for (int i = 0; i < 10; i++)
    Assert.IsTrue(test.ContainsKey(i));

string cmp;
for (int i = 0; i < 10; i++)
    Assert.IsTrue(test.TryGetValue(i, out cmp) && cmp == i.ToString());

for (int i = 0; i < 10; i++)
    Assert.IsTrue(test.Remove(i));
VB.NETCopy Code
Dim test As New LurchTableTest(Of Integer, String)()
Dim i As Integer = 0
While i < 10
    test.Add(i, i.ToString())
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Dim i As Integer = 0
While i < 10
    Assert.IsTrue(test.ContainsKey(i))
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Dim cmp As String
Dim i As Integer = 0
While i < 10
    Assert.IsTrue(test.TryGetValue(i, cmp) AndAlso cmp = i.ToString())
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Dim i As Integer = 0
While i < 10
    Assert.IsTrue(test.Remove(i))
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys